﻿@{
    ViewBag.Title = " ";
    Layout = "~/Views/Shared/_Main.cshtml";
}
@section Head{
    <style type="text/css">
        .pagTable
        {
            width: 100%;
            border-left: solid 1px #ccc;
            table-layout: fixed;
        }
        .pagTable td
        {
            height: 25px;
            border-right: 1px solid #ccc;
            border-bottom: 1px solid #ccc;
            padding-right: 3px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
    <script type="text/javascript">
        var doActionOptions = "<select onchange='return DoAction(this.options.selectedIndex,this.value)' style='width: 96%; '>"
        + "<option value=''>-请选择-</option>";

        var opts = {
            rows: 10,
            height: 450,
            url: "",
            para: {},
            idField: "Guid",
            checkbox: false,
            columns: [
                     { field: 'TaskName', title: '源系统名称', width: 30 },
                     { field: 'TaskName', title: '模型名称', width: 30 },
                     { field: 'TaskName', title: '对接系统名称', width: 30 },
                     { field: 'TaskName', title: '操作', width: 10, align: 'center',
                         formatter: function (value, rowData, rowIndex) {
                             return "<a onclick='ReadEtlLog(\"" + value + "\");' class='grid_a'>查看</a>";
                         }
                     }
                    ]

        };

        $(function () {
            $.post('/SysMenu/DBList', function (result) {
                for (var i = 0; i < result.length; i++) {
                    $("#sel_DBName").append("<option value='" + result[i].DBName + "'>" + result[i].DBName + "</option>");
                }
            });
            InitList();
        });

        function btnSelect_Click(type) {
            if (type == "S") {
                selectSourceList();
            }
            else if (type == "M") {
                selectModelList();
            }
            else if (type == "T") {
                selectTargetList();
            }
        }

        function selectSourceList() {
            showModalMany('SelectSourceList', '/SystemConfiguration/SelectSourceList?selectCount=1&dbName=' + $("#sel_DBName").val(), '810', '460',
                function (v) {
                    if (typeof (v) == "undefined") return;
                    if (v.length > 0) {
                        $('#txt_SourceSysName').val(v[0].SourceSysName);
                        $('#sel_SourceSysGuid').val(v[0].GUID);
                    }
                });
        }

        function selectModelList() {
            showModalMany('SelectModelList', '/ModelConfig/ModelList?dbName=' + $("#sel_DBName").val(), '900', '480',
            function (v) {
                if (typeof (v) == "undefined") return;
                if (v.length > 1) {
                    alert("请选择一个模型");
                }
                else if (v.length > 0) {
                    var re = /;'>(.*?)<\/a>/;
                    var value = re.exec(v[0].TableName)[1];
                    $('#txt_ModelName').val(value);
                    $('#sel_ModelGuid').val(v[0].GUID);
                }
            });
        }

        function selectTargetList() {
            showModalMany('SelectTargetList', '/EtlTarget/SelectTargetList?selectCount=1&dbName=' + $("#sel_DBName").val(), '810', '460',
                function (v) {
                    if (typeof (v) == "undefined") return;
                    if (v.length > 0) {
                        $('#txt_TargetSysName').val(v[0].TargetSysName);
                        $('#sel_TargetSysGuid').val(v[0].GUID);
                    }
                });
        }

        function btnSearch_Click() {
            InitList();
        }
        function btnSelect_Click(type) {
            if (type == "S") {
                selectSourceList();
            }
            else if (type == "M") {
                selectModelList();
            }
            else if (type == "T") {
                selectTargetList();
            }
        }
        function InitList(postUrl) { 
            opts.para.state = jv.GetDivJson($("#tableSearchDQPanel"), 4);
            opts.url = "/SysLog/SysEtlLogList?dbName=" + $("#sel_DBName").val();
            $("#DataGrid").dg(opts);
        }
           
    </script>
}
<div style="margin: 5px;">
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                结构对比查看
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table id="tableSearchDQPanel" class="searchArea" width="100%">
        <tr>
            <td>
                选择实例：
                <select id="sel_DBName">
                </select>
                源系统： <span style="width: 204px" class="combo datebox">
                    <input id="txt_SourceSysName" style="width: 180px" class="combo-text validatebox-text"
                        type="text" readonly="readonly" />
                    <span><span class="combo-arrow" style="background: url(/images/view.png) no-repeat center center"
                        onclick="btnSelect_Click('S')"></span></span>
                    <input id="sel_SourceSysGuid" class="combo-value" type="hidden" /></span> 模型：
                <span style="width: 154px" class="combo datebox">
                    <input id="txt_ModelName" style="width: 130px" class="combo-text validatebox-text"
                        type="text" readonly="readonly" />
                    <span><span class="combo-arrow" style="background: url(/images/view.png) no-repeat center center"
                        onclick="btnSelect_Click('M')"></span></span>
                    <input id="sel_ModelGuid" class="combo-value" type="hidden" /></span> 对接系统：
                <span style="width: 204px" class="combo datebox">
                    <input id="txt_TargetSysName" style="width: 180px" class="combo-text validatebox-text"
                        type="text" readonly="readonly" />
                    <span><span class="combo-arrow" style="background: url(/images/view.png) no-repeat center center"
                        onclick="btnSelect_Click('T')"></span></span>
                    <input id="sel_TargetSysGuid" class="combo-value" type="hidden" /></span>
                <input type="button" class="button" value="查看" onclick="btnSearch_Click()" />
            </td>
        </tr>
    </table>
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/edit.png" />
            </td>
            <td width="300">
                结构对比列表
            </td>
            <td align="right"> 
            </td>
        </tr>
    </table>
    <table id="DataGrid" class="pagTable" cellpadding="0" cellspacing="0">
    </table>
    <div>
        <div id="Pagination" class="pagination">
        </div>
        <div id="loading" class="loading">
            <img src="/Images/tree_loading.gif" />
        </div>
    </div>
    <div id="msg">
    </div>
</div>
